// 来源于http://res.wx.qq.com/connect/zh_CN/htmledition/js/wxLogin.js
export class WxLogin {
  constructor(e: any) {
      var r = "default";
      if (e.self_redirect === true) r = "true";
      else if (e.self_redirect === false) r = "false";

      var i:any = document.createElement("iframe");
      var n = `https://open.weixin.qq.com/connect/qrconnect?appid=${e.appid}&scope=${e.scope}&redirect_uri=${e.redirect_uri}&state=${e.state}&login_type=jssdk&self_redirect=${r}&styletype=${e.styletype || ""}&sizetype=${e.sizetype || ""}&bgcolor=${e.bgcolor || ""}&rst=${e.rst || ""}`;
      n += e.style ? `&style=${e.style}` : "";
      n += e.href ? `&href=${e.href}` : "";
      n += e.lang === "en" ? "&lang=en" : "";
      n += e.stylelite === 1 ? "&stylelite=1" : "";
      n += e.fast_login === 0 ? "&fast_login=0" : "";

      i.src = n;
      i.frameBorder = "0";
      i.allowTransparency = "true";
      i.scrolling = "no";
      i.width = "300px";
      i.height = "400px";

      var l = document.getElementById(e.id)!;
      l.innerHTML = "";
      l.appendChild(i);
  }
}